package com.woshua.mvpmodel;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.ListView;

import com.woshua.mvpmodel.adapter.GirlAdapter;
import com.woshua.mvpmodel.mvp.model.bean.GirlBean;
import com.woshua.mvpmodel.mvp.presenter.GirlPresenter;
import com.woshua.mvpmodel.mvp.view.IGirlView;
import com.woshua.mvpmodel.ui.BaseMvpActivity;

import java.util.List;

public class MainActivity extends BaseMvpActivity<IGirlView, GirlPresenter> implements IGirlView {

    private ListView lv_content;

    private ProgressDialog dialog;

    private GirlAdapter girlAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        lv_content=findViewById(R.id.lv_content);
        girlAdapter=new GirlAdapter(this);

        mPresenter.loadData();
    }

    @Override
    protected GirlPresenter createPresenter() {
        return new GirlPresenter();
    }


    @Override
    public void showLoading() {
        dialog=new ProgressDialog(this);
        dialog.show();
    }

    @Override
    public void endLoading() {
        dialog.dismiss();
    }

    @Override
    public void onResult(List<GirlBean> girls) {
        girlAdapter.setData(girls);
        lv_content.setAdapter(girlAdapter);
    }
}
